package my.controller;

import com.jfinal.aop.Before;
import com.jfinal.core.ActionKey;
import com.jfinal.core.Controller;
import my.interceptor.Login;
import my.model.Category;
import my.service.CategoryService;

import java.util.List;

/**
 * Created by Administrator on 2017/6/8.
 */
@Before(Login.class)
public class AdminController extends Controller {
    CategoryService categoryService = new CategoryService();

    public void index() {
        renderFreeMarker("index.ftl");
    }

    @ActionKey("/admin/category/list")
    public void categoryList() {
        List<Category> categories = categoryService.getAllCategories();
        setAttr("categories", categories);
        renderFreeMarker("category-list.ftl");
    }

    @ActionKey("/admin/post/add")
    public void addPost() {
        List<Category> categories = categoryService.getAllCategories();
        setAttr("categories", categories);
        renderFreeMarker("post-add.ftl");
    }

}
